﻿/*
COPYRIGHT (C) 2011-2013 Raynald Messié

THIS FILE IS PART OF SCRUMPILOT.

SCRUMPILOT IS FREE SOFTWARE: YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF 
THE GNU LESSER GENERAL PUBLIC LICENSE VERSION v2.1 AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION.

SCRUMPILOT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY; WITHOUT
EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU LESSER
GENERAL PUBLIC LICENSE FOR MORE DETAILS.

YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE ALONG WITH SCRUMPILOT. 
IF NOT, SEE <HTTP://WWW.GNU.ORG/LICENSES/>.
*/

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using ScrumPilot.Domain.BPL;
using ScrumPilot.Domain.Models;
using ScrumPilot.Helpers;

namespace ScrumPilot.Controllers
{
    [Authorize]
    public class SharedController : BaseController
    {
        [HttpGet,NoCache]
        public PartialViewResult WorkItemsList(Int32 id, Byte t)
        {
            var lstRet = new List<WorkItem>();
            var srv = new WorkItemServices(TFS);
            switch (t)
            {
                case 0: // From Project type
                    lstRet = srv.GetWorkItemsProject(id,  null, CurrentCulture);
                    break;
                case 1: // From userview
                    lstRet = srv.GetWorkItemsUser(id,  CurrentCulture);
                    break;
                case 2: // From userview : scored 
                    lstRet = srv.GetScoringWorkItemsUser(id, CurrentCulture);
                    break;
            }
            ViewBag.WILType = t;
            return PartialView(lstRet);
        }

        [HttpGet, NoCache]
        public PartialViewResult CheckedOutList(Int32 id, Byte t)
        {
            var lstRet = new List<CheckOutFile>();
            switch (t)
            {
                case 0: // From Project type
                    lstRet = (new SourcesServices(TFS)).GetCheckOutProject(id);
                    break;
                case 1: // From userview
                    lstRet = (new SourcesServices(TFS)).GetCheckOutUser(id);
                    break;
            }
            return PartialView(lstRet);
        }
    }
}